import {createRouter,createWebHistory} from 'vue-router'
import Home from '../views/Home.vue'
import Login from '../views/user/Login.vue'
import Registry from '../views/user/Registry.vue'
import NewsIndex from '../views/news/NewsIndex.vue'
import BackIndex from '../views/back/BackIndex.vue'
import NewsList from '../views/back/NewsList.vue'
import UserList from '../views/back/UserList.vue'
import NewsDetail from '../views/back/NewsDetail.vue'
import NewsEdit from '../views/back/NewsEdit.vue'

//定义路由
const routes = [
	{
		path:'/',
		component:Home,
		redirect:'/index',
		children:[{
			path:'index',
			component:NewsIndex
		}]
	},
	{
		path:'/login',
		component:Login
	},
	{
		path:'/registry',
		component:Registry
	},
	{
		path:'/back',
		component:BackIndex,
		children:[
			{
				path:'/newsList',
				component:NewsList
			},
			{
				path:'/userList',
				component:UserList
			},
			{
				path:'/newsDetail/:id',
				component:NewsDetail
			},
			{
				path:'/newsEdit/:id',
				component:NewsEdit
			}
		]
	}
]

//创建路由
const router = createRouter({
	history:createWebHistory(),
	routes
})

export default router